#include <stdlib.h>
#include <assert.h>
#include "NEW.h"
 
void *NEW(const void *_CLASS, ...)
{
    const struct Array_TD *CLASS = (struct Array_TD *) _CLASS;
    void *p = calloc(1, CLASS->size);
    assert(p);
    *(const struct Array_TD **)p = CLASS;
 
    if (CLASS->ctor) {
        va_list ap;
        va_start(ap, _CLASS);
        p = CLASS->ctor(p, &ap);
        va_end(ap);
    }
 
    return p;
}
 
void DELETE(void *self)
{
	struct Array_TD **cp = (struct Array_TD **)self;
 
    if (self && *cp && (*cp)->dtor)
        self = (*cp)->dtor(self);
 
    free(self);
}